﻿using EasyLucky.Dal.Entity;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EasyLucky.Dal.Dal
{
    public class GiftDal:BaseDal
    {
        public List<GiftEntity> QueryAll()
        {
            var db=GetClient();
            var gifts = db.Queryable<GiftEntity>().ToList();
            return gifts;
        }

        public int AddGift(GiftEntity gift)
        {
            var db = GetClient();
            int id = db.Insertable<GiftEntity>(gift).ExecuteReturnIdentity();
            return id;
        }

        public int DeleteGift(GiftEntity gift)
        {
            var db = GetClient();
            int cnt = db.Deleteable<GiftEntity>(gift.Id).ExecuteCommand();
            return cnt;
        }

        public int UpdateGift(GiftEntity gift)
        {
            var db = GetClient();
            int cnt =  db.Updateable<GiftEntity>(gift).ExecuteCommand();
            return cnt;
        }
    }
}
